#include <iostream>
#include <jsoncpp/json/json.h>

using namespace std;

int main()
{
    // Json k v {a : 1}
    // Value 万能类型

    Json::Value part;
    part["hehe"] = "hehe";
    part["haha"] = "haha";


    Json::Value root;
    root["x"] = 100;
    root["y"] = 200;
    root["op"] = '+';
    root["str"] = "this is a + oper";
    root["test"] = part;
    Json::FastWriter w;
    string ret = w.write(root);

    cout << ret << endl;

    Json::Value v;
    Json::Reader r;
    r.parse(ret, v);
    
    int x = v["x"].asInt();
    int y = v["y"].asInt();
    char op = v["op"].asInt();
    std::string str = v["str"].asString();

    cout << x << endl;
    cout << op << endl;
    cout << y << endl;
    cout << str << endl;


    return 0;
}